package framework.director;

import framework.bean.NeedScanPackageBean;
import framework.needscan.controller.ControllerScanner;
import framework.needscan.inject.InjectScanner;
import framework.util.ClassReflectUtil;

/**
 * @author 马洁
 * @date 2020/3/12 - 22:00
 */
public class FirstDirector extends BaseDirector {
    private InjectScanner injectScanner = InjectScanner.getInstance();
    private ControllerScanner controllerScanner = ControllerScanner.getInstance();

    public FirstDirector(NeedScanPackageBean needScanPackageBean) {
        super(needScanPackageBean);
    }

    @Override
    public void needDoForClass(Class<?> cls) {
        if (ClassReflectUtil.isNotInterfaceAndAbstract(cls)) {
            injectScanner.scan(cls);
            controllerScanner.scan(cls);
        }
//        System.out.println(controllerScanner.getRequestMapping());
    }

    @Override
    public void start(String reqUrl) {
        controllerScanner.handleReq(reqUrl);
    }
}
